package com.sun.demo;


import com.sun.demo.job.Job03;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
public class SpringJob02 {

    @Autowired
    private Scheduler scheduler;

    @Bean
    public JobDetail springJobDetail(){
        return JobBuilder.newJob(Job03.class)
                .withIdentity("springJobDetail")
                .storeDurably().build();
    }

    @Bean
    public Trigger springTrigger(){
        return TriggerBuilder.newTrigger()
                .forJob("springJobDetail")
                .startNow()
                .build();
    }

}
